﻿using Bentley.DgnPlatformNET;
using Bentley.GeometryNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheccCoverplateCulvertAssemble.Mesh
{
    public class MeshProcess : ElementGraphicsProcessor
    {
        private readonly FacetOptions _options;
        private readonly List<PolyfaceHeader> _output;
        private DTransform3d _currentTransform = DTransform3d.Identity;

        public MeshProcess(FacetOptions opts, ref List<PolyfaceHeader> outputPoly)
        {
            _options = opts;
            _output = outputPoly;
        }

        public override FacetOptions GetFacetOptions()
        {
            return _options;
        }

        public override bool ExpandLineStyles()
        {
            return false;
        }

        public override bool ExpandPatterns()
        {
            return false;
        }

        public override bool ProcessAsBody(bool isCurved)
        {
            return false;
        }

        public override bool ProcessAsFacets(bool isPolyface)
        {
            return true;
        }

        public override bool WantClipping()
        {
            return true;
        }

        public override void AnnounceTransform(DTransform3d trans)
        {
            _currentTransform = trans;
        }

        public override BentleyStatus ProcessFacets(PolyfaceHeader meshData, bool filled)
        {
            var header = new PolyfaceHeader();
            header.CopyFrom(meshData);
            header.Transform(ref _currentTransform, false);
            _output.Add(header);
            return BentleyStatus.Success;
        }
    }
}
